t = ""
A = []
def prost(x):
    B = []
    for i in range(1,x+1):
        if x % i == 0:
            B.append(i)
    if len(B) == 2:
        return True
    else:
        return False
for x in range(100,1000):
    if prost(x) == True:
        A.append(x)
stroka = input().split()
for s in stroka:
    if s == "zero":
        x = 0
    elif s == "one":
        x = 1
    elif s == "two":
        x = 2
    elif s == "three":
        x = 3
    elif s == "four":
        x = 4
    elif s == "five":
        x = 5
    elif s == "six":
        x = 6
    elif s == "seven":
        x = 7
    elif s == "eight":
        x = 8
    elif s == "nine":
        x = 9
    t = t + str(x)
mini = 10000000
A = A[::-1]
t = int(t)
if int(t) >= 100 and int(t) < 1000 and len(stroka) == 3:
    for i in range(len(A)):
        razn = abs(t - A[i])
        if razn <= mini:
            mini = razn
            chislo = A[i]
    print(chislo)
else:
    print("Wrong input")




